package com.lpit.controller;

import com.lpit.pojo.CommentReply;
import com.lpit.result.ResponseResult;
import com.lpit.service.CommentManagementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 评论管理
 */
@RestController
@RequestMapping("/comment/management")
public class CommentManagementController {
    @Autowired
    private CommentManagementService commentManagementService;

    /**
     * 查看评论
     * @return
     */
    @GetMapping
    ResponseResult queryCommentAll(Integer id,Integer page,Integer pageSize){

        return commentManagementService.get(id, page, pageSize);
    }

    /**
     * 删除评论
     * @return
     */
    @DeleteMapping("/{id}")
    ResponseResult delete(@PathVariable Integer id){

        return commentManagementService.deleteComment(id);
    }

    /**
     * 评论置顶
     * @param id
     * @return
     */
    @PutMapping("/{id}")
    ResponseResult commentTop(@PathVariable Integer id){

        return commentManagementService.commentTop(id);
    }

    /**
     * 回复评论
     * @return
     */
    @PostMapping
    ResponseResult addComment(@RequestBody CommentReply commentReply){

        return commentManagementService.addComment(commentReply);
    }
}
